<layout name="popup" />
<block name="content">
	<input type="hidden" name="ajax" id="ajax" value="1">
	<div class="popup-header">
		<h1>修改密码</h1>
		<i class="mid"></i>
		<a class="btn btn-normal" onclick="save();">确定</a>
		<a class="btn btn-return" onclick="close_popup();">取消</a>
	</div>
	<div class="popup-body">
		<div class="popup-body-scroll">
			<div class="popup-content">
				<form id="form_data" name="form_data" method="post" >
					<input type="hidden" name="user_id" id="user_id">
					<div class="box">
						<label class="input-label" >新密码：</label>
						
							<input type="password" name="password" id="password" value=""  class="input col-20">
						</div>
					</div>
					<div class="box">
						<label class="input-label" >确认密码：</label>
						
							<input type="password" name="confirm_password" id="confirm_password" value=""  class="input col-20"/>
						</div>
					</div>
					<div class="box">
						<label class="input-label" ></label>
						<span id="msg" ></span>
					</div>
				</form>
			</div>
		</div>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		var index = parent.layer.getFrameIndex(window.name);
		layui.use(['global'], function() {
			var user_id = '';
			$("#form_user input[name='user_id[]']:checked", parent.document).each(function() {
				user_id += this.value + ',';
			});

			$("#user_id").val(user_id);
			var fn = {
				save : function() {
					var msg = "";
					new_pwd = $("#password").val();
					confirm_pwd = $("#confirm_password").val();
					if (new_pwd == confirm_pwd) {
						var vars = $("#form_data").serialize();
						send_ajax("{:url('reset_pwd')}", vars, function(data) {
							layer.msg(data.info, {
								time : 1200
							}, function() {
								parent.layer.close(index);
							});
						});
					} else {
						layer.msg("密码不一致");
					}
				},
				close_popup : function() {
					parent.layer.close(index);
				},
				select_pid : function() {
					winopen("{:url('select_pid')}", 560, 470);
				},
			};
			win_exp(fn);
			$("#password").keydown(function() {
				s = $(this).val();
				t = check_password(s);
				if (t == 0) {
					$("#msg").html("密码过短");
					$("#msg").css("color", "red");
				}
				if (t == 1) {
					$("#msg").html("密码强度差");
					$("#msg").css("color", "red");
				}
				if (t == 2) {
					$("#msg").html("密码强度良好");
					$("#msg").css("color", "blue");
				}
				if (t == 3) {
					$("#msg").html("密码强度高");
					$("#msg").css("color", "blue");
				}
			});

			$("#confirm_password").keyup(function() {
				new_pwd = $("#password").val();
				confirm_pwd = $(this).val();
				if (new_pwd != confirm_pwd) {
					$("#msg").html("密码不一致");
					$("#msg").css("color", "red");
				} else {
					$("#msg").html("密码一致");
					$("#msg").css("color", "blue");
					$("#status").val("true");
				}
			});
		});

	</script>
</block>